package com.hbut.service.impl;

import com.hbut.dao.UserDao;
import com.hbut.service.UserService;
import com.hbut.vo.Users;

import java.util.List;


public class UserServiceImpl implements UserService {

    private UserDao userDao = UserDao.getInstance();

    @Override
    public Users userLogin(Users users) {
        // 进行业务逻辑处理
        return userDao.userLogin(users);
    }

    @Override
    public List<Users> queryUserList(String username) {
        if(username!=null&&!"".equals(username)){
            username = "%" + username + "%";
        }
        return userDao.queryUserList(username);
    }

    @Override
    public int insertUser(Users users) {
        int row = 0;
        if(users.getId()==null){
            row = userDao.insertUser(users);
        }else {
            row = userDao.updateUser(users);
        }
        return row;
    }

    @Override
    public int deleteUser(String id) {
        return userDao.deleteUser(id);
    }

    @Override
    public Users queryUserById(String id) {
        return userDao.queryUserById(id);
    }
}
